// 调用nodejs安装的thrift依赖包
var thrift = require('thrift');
// 调用win10下thrift命令自动生成的依赖包
var printService = require('./gen-nodejs/printService.js');

// 配置thrift的connection信息
var connection = thrift.createConnection(host = '127.0.0.1', port = 8080);
// 根据配置的connection创建client
var client = thrift.createClient(printService, connection);
// 监听connection是否error
connection.on("error", function (e) {
    console.log(e);
});

// 定义一个json格式数据
var dic = {
    name: "yun",
    age: "23"
};
console.log(dic.name);
// 把json数据转成字符串格式
dic = JSON.stringify(dic);
// client调用thrift接口定义好的方法函数
client.print_msg(dic, function (err, res) {
    if (err) {
        console.log('err:', err);
    } else {
        console.log('res:', res);
    };
});
// 问题：如何关闭一个client的connection？